function splitString(str) {
  const result = [];
  let current = "";
  let isTrue = false;

  for (let i = 0; i < str.length; i++) {
    const char = str[i];

    if (char === '"') {
      if (isTrue) {
        // 双引号结束，添加当前内容到结果数组
        if (current.length > 0) {
          result.push(current);
          current = "";
        }
      }
      isTrue = !isTrue;
    } else if (char === " " && !isTrue) {
      // 遇到空格且不在双引号内时，添加当前内容到结果数组
      if (current.length > 0) {
        result.push(current);
        current = "";
      }
    } else {
      current += char;
    }
  }

  // 处理剩下片段
  if (current.length > 0) {
    result.push(current);
  }

  return result;
}

const input = 'ab c "abc adabvfdha" def "dddd"';
const output = splitString(input);
console.log(output);
